//
//  UserPage.swift
//  newsApp
//
//  Created by Doo Psyist on 2020/5/12.
//  Copyright © 2020 Doo Psyist. All rights reserved.
//

import SwiftUI

struct UserPage: View {

    var body: some View {
        NavigationView {
            VStack(alignment: .leading) {
                HStack {
                    Text("Info")
                        .font(.system(size: 50, design: .rounded))
                        .foregroundColor(Color.orange)
                        .bold()
                        .shadow(radius: 1)
                }
                
                UserPageSub2(newsListItem: newsList[0])
                    .frame(height:250)
                    .padding(.top,0)
                
                
                HStack {
                    Image(systemName: "person.crop.circle.fill")
                        .imageScale(.large)
                        .foregroundColor(.black)
                        .shadow(radius: 1)
                    Text("dukalee@foxmail.com")
                        .font(.system(size: 15, design: .rounded))
                        .foregroundColor(Color.blue)
                        .bold()
                        .shadow(radius: 1)
                    Spacer()
                    Text("176-9547-1833")
                        .font(.system(size: 15, design: .rounded))
                        .foregroundColor(Color.blue)
                        .shadow(radius: 1)
                }
                    .padding(.bottom, 20)
                    .padding()
                    .background(Color.orange)
                    .cornerRadius(20)
                    .shadow(radius: 10)
                //HStack {
                //NavigationView {
                List {
                    HStack {
                        Image(systemName: "suit.heart")
                            .imageScale(.large)
                            .foregroundColor(.black)
                            .shadow(radius: 1)
                            .padding()
                        NavigationLink(destination: MyFavorites()) {
                            Text("Favorites")
                                .font(.system(size: 20, design: .rounded))
                                .foregroundColor(Color.black)
                            //.bold()
                            .shadow(radius: 1)
                        }

                    }.padding()
                        .background(Color.blue)
                        .cornerRadius(20)
                        .shadow(radius: 10)



                    HStack {
                        Image(systemName: "pencil.and.ellipsis.rectangle")
                            .imageScale(.large)
                            .foregroundColor(.black)
                            .shadow(radius: 1)
                            .padding()
                        NavigationLink(destination: MyComments()) {
                            Text("Comments")
                                .font(.system(size: 20, design: .rounded))
                                .foregroundColor(Color.black)
                            //.bold()
                            .shadow(radius: 1)
                        }

                    }
                        .padding()
                        .background(Color.blue)
                        .cornerRadius(20)
                        .shadow(radius: 10)

                    HStack {
                        Image(systemName: "doc.text")
                            .imageScale(.large)
                            .foregroundColor(.black)
                            .shadow(radius: 1)
                            .padding()
                        NavigationLink(destination: MyRecords()) {
                            Text("Access Records")
                                .font(.system(size: 20, design: .rounded))
                                .foregroundColor(Color.black)
                                .shadow(radius: 1)
                        }

                    }.padding()
                        .background(Color.blue)
                        .cornerRadius(20)
                        .shadow(radius: 10)



                }
                    .navigationBarTitle("")
                    .navigationBarHidden(true)

                // }

            }












            /*   VStack(alignment: .leading) {
                Text("block1")
                    .font(.title)
                    .padding(.bottom, 8)
                HStack {
                    Text("info1-1")
                        .font(.headline)
                    Spacer()
                    Text("detail1-1")
                        .font(.subheadline)
                }
                HStack {
                    Text("info1-2")
                        .font(.headline)
                    Spacer()
                    Text("detail1-2")
                        .font(.subheadline)
                }
                HStack {
                    Text("info1-3")
                        .font(.headline)
                    Spacer()
                    Text("detail1-3")
                        .font(.subheadline)
                }
            }
            .padding(.bottom, 20)
            VStack(alignment: .leading) {
                Text("block2")
                    .font(.title)
                    .padding(.bottom, 8)
                HStack {
                    Text("info2-1")
                        .font(.headline)
                    Spacer()
                    Text("detail2-1")
                        .font(.subheadline)
                }
                HStack {
                    Text("info2-2")
                        .font(.headline)
                    Spacer()
                    Text("detail2-2")
                        .font(.subheadline)
                }
                HStack {
                    Text("info2-3")
                        .font(.headline)
                    Spacer()
                    Text("detail2-3")
                        .font(.subheadline)
                }
            }
            .padding(.bottom, 20)
            VStack(alignment: .leading) {
                Text("block3")
                    .font(.title)
                    .padding(.bottom, 8)
                HStack {
                    Text("info3-1")
                        .font(.headline)
                    Spacer()
                    Text("detail3-1")
                        .font(.subheadline)
                }
                HStack {
                    Text("info3-2")
                        .font(.headline)
                    Spacer()
                    Text("detail3-2")
                        .font(.subheadline)
                }
                HStack {
                    Text("info3-3")
                        .font(.headline)
                    Spacer()
                    Text("detail3-3")
                        .font(.subheadline)
                }
            }
            .padding(.bottom, 20) */
            Spacer()
            Text("Version: " + String(UIApplication.appVersion ?? "empty"))
                .font(.subheadline)
        }

        //}
        .padding()



    }
}

extension UIApplication {
    static var appVersion: String? {
        return Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String
    }
}

struct UserPage_Previews: PreviewProvider {
    static var previews: some View {
        UserPage()
    }
}
